<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!doctype html>
<html>
<head>
	<title>保养提醒</title>
	<style type="text/css">
		#attr2,#attr3{display: none;}
	</style>

	<script type="text/javascript">
		var pageListUrl = "<c:url value="/remind/service/list" />";
		var saveUrl = "<c:url value="/promotion/customer/save" />";

		var detailTbodyTemplateID = "detailTbodyTemplate";
		var detailTbodyID = "detailTbody";
		var pageToolID = "pageTool";

		var editTemplateID = "edit-template";
		var editFormID = "nsForm";
		var searchFormID = "searchForm";


		$(function () {
			toPage(1);
			changeMaintenanceItem();
		});

	</script>

</head>


<body  class="list-body">



<div class="content">
	<div class="title fix">
		<h3 class="b f14 fl">保养提醒</h3>
		<%-- <div class="f14 fl " style="margin-top: 30px; margin-left:30px; "><a href='<c:url value="/remind/sms/manage/${dealerNum}" />' >短信余额<label class="msg-label orange b" id="smsQuantity">${smsQuantity}</label></a></div> --%>
		<div class="btns fr">
			<%--<button class="green" onclick="add()">新增</button>--%>
			<%--<button class="orange">返回</button>--%>
		</div>
	</div>

	<div class="main">
		<div class="inquiry">
			<form id="searchForm">
				<input type="hidden" name="currentPage" value="1">
				<input type="hidden" name="toolStyle" value="pms">
				<input type="hidden" name="limit" value="10">
				<input type="hidden" name="method" value="toPage">
				<input type="hidden" name="dealerNum" value="${dealerNum}">

				<div class="group"><label>建议保养月份：</label><input type="text" name="nextCalcDateParam" id="nextCalcDateParam" value="${currentMonth}" class="Wdate"  onFocus="WdatePicker({dateFmt:'yyyy-MM',minDate:'2016-01'})" autocomplete="off" /></div>
				<div class="group"><label>保养类型：</label>
					<select name="maintenanceItem" id="maintenanceItem" onchange="changeMaintenanceItem()">
						<option value="">--全部--</option>
						<%--<option value="轮胎" ${'轮胎' eq maintenanceItem ? 'selected':''}>轮胎</option>
						<option value="机油" ${'机油' eq maintenanceItem ? 'selected':''}>机油</option>
						<option value="制动" ${'制动' eq maintenanceItem ? 'selected':''}>制动</option>
						<option value="轮胎换位" ${'轮胎换位' eq maintenanceItem ? 'selected':''}>轮胎换位</option>--%>
						<c:forEach items="${serviceRemindItems}" var="g">
							<option value="${g}" ${g eq maintenanceItem ? 'selected':''}>${g}</option>
						</c:forEach>
					</select>
				</div>
				<div class="group"><label>客户分类：</label>
					<select name="customerGroupId" id="customerGroupId">
						<option value="">--全部--</option>
						<c:forEach items="${customerGroups}" var="g">
							<c:if test="${!g.isCustom}">
								<option value="${g.id}">${g.groupName}</option>
							</c:if>
						</c:forEach>
						<option value="CFXF">重复消费客户</option>
						<option value="QZKH">潜在消费客户</option>
						<optgroup label="自定义客户分类">
							<c:forEach items="${customerGroups}" var="g">
								<c:if test="${g.isCustom}">
									<option value="${g.id}">${g.groupName}</option>
								</c:if>
							</c:forEach>
						</optgroup>
					</select>
					<div class="" style="display: inline;">
                        <button class="green" type="button" style="background: #02af4f;border: none;font-size: 16px;font-weight: bold;color: #FFF;" onclick="mamageCustomerStyle('${send}','${remindMonth}')">+</button>
                    </div>
				</div>
				<div class="group"><label>车辆品牌：</label>
					<select name="carBrand" id="carBrand">
						<option value="">--全部--</option>
						<c:forEach items="${vehicleBrands}" var="vb">
							<option value="${vb.code}">${vb.codeValue}</option>
						</c:forEach>
					</select>
				</div>
				<div class="group"><label>发送状态：</label>
					<select name="remindStatus" id="remindStatus">
						<option value="">--全部--</option>
						<option value="1" ${'1' eq send ? 'selected':''}>已发送</option>
						<option value="0" ${'0' eq send ? 'selected':''}>未发送</option>
					</select>
				</div>
				<div class="group"><label>一年累计进店次数：</label>
					<%--<select name="countOfToStoreParam" id="countOfToStoreParam">
						<option value="">--全部--</option>
						<option value="1">小于5次</option>
						<option value="2">5-10次</option>
						<option value="3">10-15次</option>
						<option value="4">15次以上</option>
					</select>--%>
					<input class="mini" type="text" name="countOfToStoreMin" id="countOfToStoreMin" value="" />
					- <input class="mini" type="text" id="countOfToStoreMax" name="countOfToStoreMax" value="" />
				</div>
				<div class="group">
					<label>一年累计消费金额：</label><input class="mini" type="text" name="moneyOfYearMin" id="moneyOfYearMin" value="" />
					- <input class="mini" type="text" id="moneyOfYearMax" name="moneyOfYearMax" value="" /></div>
				<div class="btns"><button type="button" class="bottleGreen vm" onclick="toPage(1)">查询</button></div>
			</form>
		</div>
		<div class="table">
			<table width="100%">
				<thead>
				<tr>
					<th width="40"><input type="checkbox" name="name" value=" " title="全选当前页" onclick="selectAll(this, 'checkSRID')" /></th>
					<%--<th width="50">序号</th>--%>
					<th width="120">客户姓名</th>
					<th width="80">手机号码</th>
					<th width="60">车牌号</th>
					<th width="60">车品牌</th>
					<th width="">微信会员</th>
					<th width="">保养提醒项目</th>
					<%--<th width="">上次服务项目</th>--%>
					<th width="">上次保养时间</th>
					<th width="">上次保养里程</th>
					<th width="">最近一年累计进店次数</th>
					<th width="">最近一年累计消费金额</th>
					<th width="">上次保养项目</th>
					<th width="">上次提醒日期</th>
					<th width="">发送次数</th>
					<th width="">发送历史</th>
				</tr>
				</thead>
				<tbody id="detailTbody" class="detailTr"></tbody>
			</table>
		</div>

		<div class="pageTool" id="pageTool"></div>

		<div><span style="font-size:12px; color:red;">注：微信会员将通过微信发送保养提醒</span></div>

		<div class="cg-fieldset">
			<fieldset>
				<legend>促销信息</legend>
				<div class="promotion-box" id="hqPromotion"><label>
					<input type="radio" name="promotionType" value="1"/>总部促销
					</label> <<label style="font-weight: bold;color: #02af4f;" id="loadHqPromotionBox"></label>>
					<input type="hidden" name="hqPromotionId" id="hqPromotionId">
				</div>
				<div class="promotion-box" id="customerizedPromotion" ><label>
					<input type="radio" name="promotionType" value="2"/>自定义促销
					</label>
					<select name="customerPromotionId" id="customerPromotionId">
						<option value="">--请选择--</option>
					</select>
					<div class="btns" style="display: inline;"><button id="createPromotion" class="green min" onclick="add(loadCustomerPromotion)">新建自定义促销</button></div>
				</div>
				<div class="promotion-box">
					<label>
					<input type="radio" name="promotionType" id="noPromotion" checked value="0"/>无促销
					</label>
				</div>
				<div class="btns tl"><button class="green " onclick="reviewSms()">短信预览</button></div>
			</fieldset>

			<fieldset>
				<legend>短信预览</legend>
				<div id="reviewSmsBox"></div>
			</fieldset>
		</div>
		<div class="btns tl tc">
			<button class="green " onclick="sendSelected()">发送给当前选择客户</button>
			<button class="green " onclick="sendAll()">发送给所有符合条件的客户</button>
		</div>
		<div class="mb10"></div>
	</div>
</div>
<script type="text/javascript">
	var loadCustomerPromotion = function loadCustomerPromotion(maintenanceType){
		var $sel = $("#customerPromotionId");

		var options = [];
		options.push('<option value="">--请选择--</option>');

		$.ajax({
			type: "GET",
			url: '<c:url value="/promotion/customer/list/${dealerNum}" />',
//			data: {maintenanceType: maintenanceType},
			data: {},
			dataType: "json",
			cache:false,
			success: function(data){
				if (data.success) {
					$sel.empty();

					$.each(data.data, function(key, value) {
						options.push('<option value="'+ value.id +'">' + value.promotionalContent + "【有效期" + value.periodOfValidity +  timeUnitData[value.timeUnit] + '】</option>');
					});
					$sel.html(options.join(''));

				} else {
					ns.error(data.message);
				}

			},
			error: function(){
				//ns.error("操作失败，请重试！");
			}
		});
	};


	var loadHqPromotion = function loadHqPromotion(maintenanceType){
		var $hqPromotionBox = $("#loadHqPromotionBox");
		$hqPromotionBox.html('');
		$("#hqPromotionId").val('');
		if(maintenanceType.length == 0){
			$hqPromotionBox.html('根据保养类型自动匹配');
			return;
		}
		$.ajax({
			type: "GET",
			url: '<c:url value="/promotion/hq/selected" />',
			data: {maintenanceType:maintenanceType},
//			data: {},
			dataType: "json",
			cache:false,
			success: function(data){
				if (data.success) {
					if(data.data != null){
						$hqPromotionBox.html(data.data.promotionalContent+ "【有效期" + data.data.periodOfValidity +  timeUnitData[data.data.timeUnit] + '】');
						$("#hqPromotionId").val(data.data.id);
					}

				} else {
					ns.error(data.message);
				}

			},
			error: function(){
				//ns.error("操作失败，请重试！");
			}
		});
	};

	function changeMaintenanceItem(){
		var maintenanceType = $("#maintenanceItem").val();
		toPage(1);
		loadHqPromotion(maintenanceType);
		loadCustomerPromotion(maintenanceType);
		//update promotion option with promotion privilege
		console.log('${dealerPromotionPrivilege.headerquartersPromotion}');
		if('ENABLED' != '${dealerPromotionPrivilege.headerquartersPromotion}') {
			$("#hqPromotion").css("display","none");
		}else{
			$("input[type=radio][name='promotionType'][value='1']").prop("checked", true);
		}
		if('ENABLED' != '${dealerPromotionPrivilege.customerizedPromotion}') {
			$("#customerizedPromotion").css("display","none");
		}
	}



	function reviewSms(){
		var $reviewSmsBox = $("#reviewSmsBox");

		var nsIndex = ns.load("正在加载数据...");

		$.ajax({
			type: "GET",
			url: '<c:url value="/remind/service/sms/review" />',
			data: {
				maintenanceItem: $("#maintenanceItem").val(),
				dealerNum: '${dealerNum}',
				promotionType: $("input[type=radio][name=promotionType]:checked").val(),
				hqPromotionId: $("#hqPromotionId").val(),
				customerPromotionId: $("#customerPromotionId").val()
			},
			dataType: "json",
			async: true,
			cache:false,
			success: function(data){
				ns.close(nsIndex);
				if (data.success) {
					if(data.data != null){
						$reviewSmsBox.html(data.data.smsContent);
					}

				} else {
					ns.error(data.message);
				}

			},
			error: function(){
				ns.close(nsIndex);
				ns.error("操作失败，请重试！");
			}
		});
	}

	function sendAll(){
		var $reviewSmsBox = $("#reviewSmsBox");
		var _maintenanceItem = $("#maintenanceItem").val();

		var nsIndex = ns.load("正在加载数据...");

		var data  = {
			maintenanceItem: _maintenanceItem,
			dealerNum: '${dealerNum}',
			promotionType: $("input[type=radio][name=promotionType]:checked").val(),
			hqPromotionId: $("#hqPromotionId").val(),
			customerPromotionId: $("#customerPromotionId").val(),

				nextCalcDateParam: $("#nextCalcDateParam").val(),
				customerGroupId: $("#customerGroupId").val(),
				carBrand: $("#carBrand").val(),
				remindStatus: $("#remindStatus").val(),
				countOfToStoreParam: $("#countOfToStoreParam").val(),
				moneyOfYearMin: $("#moneyOfYearMin").val(),
				moneyOfYearMax: $("#moneyOfYearMax").val()

		};

		$.ajax({
			type: "POST",
			url: '<c:url value="/remind/service/sms/sendAll" />',
			data: data,
			dataType: "json",
//			contentType : 'application/json',
			async: true,
			cache:false,
			success: function(data){
				ns.close(nsIndex);
				if (data.success) {
					ns.ok(data.message, function(){toPage(1)});
					loadSmsQuantity();
					$("#reviewSmsBox").text("");
					$("input[type=radio][name=promotionType]:checked").prop("checked","false");
					$("#noPromotion").prop("checked","true");
				} else {
					ns.error(data.message);
				}

			},
			error: function(){
				ns.close(nsIndex);
				ns.error("操作失败，请重试！");
			}
		});
	}

	function sendSelected(){
		var $reviewSmsBox = $("#reviewSmsBox");
		var _maintenanceItem = $("#maintenanceItem").val();

		var selectSRIdArray = new Array();

		$("input[type=checkbox][name='checkSRID']:checked").each(function() {
			selectSRIdArray.push($(this).val());
		});

		if(selectSRIdArray.length < 1){
			ns.error("请先选择要发送的客户");
			return;
		}


		var data  = {
			maintenanceItem: _maintenanceItem,
			dealerNum: '${dealerNum}',
			promotionType: $("input[type=radio][name=promotionType]:checked").val(),
			hqPromotionId: $("#hqPromotionId").val(),
			customerPromotionId: $("#customerPromotionId").val(),

				nextCalcDateParam: $("#nextCalcDateParam").val(),
				customerGroupId: $("#customerGroupId").val(),
				carBrand: $("#carBrand").val(),
				remindStatus: $("#remindStatus").val(),
				countOfToStoreMin: $("#countOfToStoreMin").val(),
				countOfToStoreMax: $("#countOfToStoreMax").val(),
				moneyOfYearMin: $("#moneyOfYearMin").val(),
				moneyOfYearMax: $("#moneyOfYearMax").val()

			,srId : selectSRIdArray

		};

		var nsIndex = ns.load("正在处理数据，请稍等...");

		$.ajax({
			type: "POST",
			url: '<c:url value="/remind/service/sms/sendSelected" />',
			data: data,
			dataType: "json",
			async: true,
			cache:false,
			traditional :true,
			success: function(data){
				ns.close(nsIndex);
				if (data.success) {
					ns.ok(data.message, function(){toPage(1)});
					loadSmsQuantity();
					$("#reviewSmsBox").text("");
					$("input[type=radio][name=promotionType]:checked").prop("checked","false");
					$("#noPromotion").prop("checked","true");
				} else {
					ns.error(data.message);
				}

			},
			error: function(){
				ns.close(nsIndex);
				ns.error("操作失败，请重试！");
			}
		});
	}


	var historyParam = {
		customerId : "",
		vehicleId : "",
	};

	function showSendSmsList(customerId, vehicleId,customerName){
		historyParam["customerId"] = customerId;
		historyParam["vehicleId"] = vehicleId;

		layer.open({
			type: 1,
			title: '发送历史',
			area: '850px',
			offset: '30px',
			shadeClose: true,
			content: template("historyTemplate", {}),
			success:function(){
				loadHistory(1, 10);
			}
		});
	}

	function loadHistory(page, limit) {

		var $searchForm = $("#historySearchForm");

		if(page) {
			$searchForm.find("input[name=currentPage]").val(page);
		}

		if(limit) {
			$searchForm.find("input[name=limit]").val(limit);
		}

		$searchForm.find("input[name=customerId]").val(historyParam.customerId);
		$searchForm.find("input[name=vehicleId]").val(historyParam.vehicleId);


		var loadIndex = ns.load("数据加载中...");

		$.ajax({
			type: "POST",
			url: '<c:url value="/remind/service/sms/list" />',
			dataType: "json",
			data: $searchForm.serialize(),
			async: true,
			success: function (data) {
				ns.close(loadIndex);
				if (data.success) {
					var html = template("historyDetailTbodyTemplate", data.data);

					$("#historyDetailTbody").html(html);
					$("#historyPageTool").html(data.data.pageToolHtml);
				} else {
					ns.error(data.message);
				}

			},
			error: function () {
				ns.close(loadIndex);
				ns.error('数据加载失败！');
			}
		});
	}


	function loadSmsQuantity(){
		$.ajax({
			type: "POST",
			url: '<c:url value="/remind/sms/quota/${dealerNum}" />',
			dataType: "json",
			data: {},
			async: true,
			success: function (data) {
				if (data.success) {
					$("#smsQuantity").html(data.data);
				} else {
					$("#smsQuantity").html('');
				}

			},
			error: function () {
				$("#smsQuantity").html('');
			}
		});
	}

	function mamageCustomerStyle(send,remindMonth){
		location ='<c:url value="/customerGroup/manage/${dealerNum}?returnBtnEnabled=remind&send='+send+'&remindMonth='+remindMonth+'" />';
	}

	function showConsumeHistory(dealerId) {
		//console.log(dealerId);

		layer.open({
			type: 1,
			title: '消费历史',
			area: '850px',
			offset: '30px',
			shadeClose: true,
			content: template("consumeHistoryTemplate", {}),
			success:function(){
				loadConsumeHistory(1, 10);
			}
		});
	}

	function loadConsumeHistory(page, limit) {

		var $searchForm = $("#consumeHistorySearchForm");

		if(page) {
			$searchForm.find("input[name=currentPage]").val(page);
		}

		if(limit) {
			$searchForm.find("input[name=limit]").val(limit);
		}

		$searchForm.find("input[name=customerId]").val(historyParam.customerId);

		var loadIndex = ns.load("数据加载中...");

		$.ajax({
			type: "POST",
			url: '<c:url value="/remind/service/consume/list" />',
			dataType: "json",
			data: $searchForm.serialize(),
			async: true,
			success: function (data) {
				ns.close(loadIndex);
				if (data.success) {
					var html = template("consumeHistoryDetailTbodyTemplate", data.data);

					$("#consumeHistoryDetailTbody").html(html);
					$("#consumeHistoryPageTool").html(data.data.pageToolHtml);
				} else {
					ns.error(data.message);
				}

			},
			error: function () {
				ns.close(loadIndex);
				ns.error('数据加载失败！');
			}
		});
	}
</script>

<script id="detailTbodyTemplate" type="text/html">
	{{each items as v i}}
	<tr id="{{v.id}}" >
		{{if null != v.wechatMember && null != v.wechatMember.match('是') }}
			<td width="40"><input type="checkbox" name="checkSRID" value="{{v.serviceRemindId}}" style="visibility:hidden;"/></td>
		{{else}}
			<td width="40"><input type="checkbox" name="checkSRID" value="{{v.serviceRemindId}}" /></td>
		{{/if}}
		<%--<td>{{start + i + 1}}</td>--%>
		<td>{{v.memberName}}</td>
		<td>{{v.mobilePhone}}</td>
		<td>{{v.carPlate}}</td>
		<td>{{v.carBrand}}</td>
		<td>{{v.wechatMember}}</td>
		<td>{{v.maintenanceItem}}</td>
		<%--<td></td>--%>
		<td>{{v.lastMaintenanceDate}}</td>
		<td>{{v.lastMaintenanceMileage}}</td>
		<td>{{v.countOfToStore}}</td>
		<td>{{v.moneyOfYear}}</td>
		<td>{{v.lastMaintenanceItemDisplay}}</td>
		<td>{{v.lastRemindDate}}</td>
		<td>{{v.countOfSMS}}</td>
		<td class="operate_td">
			<a href='javascript:void(0);' onclick="showSendSmsList('{{v.customerId}}', '{{v.carId}}','{{v.memberName}}')">发送历史</a>
		</td>
	</tr>
	{{/each}}
	{{if items.length == 0}}
	<tr>
		<td colspan="11" class="none-data-tip">没有相关数据</td>
	</tr>
	{{/if}}
</script>



<script id="edit-template" type="text/html">
	<form id="nsForm" method="post" class="form-box">
		<input type="hidden" name="id" value="{{id}}"/>
		<input type="hidden" name="dealerId" value="${dealerNum}"/>

		<div class="box-body">
			<%--<div class="form-group">
				<label>保养类型</label>
				<select name="maintenanceType">
					<option value="">--请选择--</option>
					<option value="轮胎" {{maintenanceType == '轮胎'?'selected':''}}>轮胎</option>
					<option value="机油" {{maintenanceType == '机油'?'selected':''}}>机油</option>
					<option value="制动" {{maintenanceType  == '制动'?'selected':''}}>制动</option>

				</select>
			</div>--%>
			<div class="form-group">
				<label>促销类型</label>
				<select name="attr1" id="attr1" onchange="changeType()">
					<option value="">--请选择--</option>
					<option value="0" {{attr1 == '0'?'selected':''}}>买赠</option>
					<option value="1" {{attr1 == '1'?'selected':''}}>买减</option>
					<option value="2" {{attr1 == '2'?'selected':''}}>直接送抵扣券</option>
					<option value="3" {{attr1 == '3'?'selected':''}}>直接送产品</option>
					<option value="4" {{attr1 == '4'?'selected':''}}>自定义</option>

				</select>
			</div>
			<div class="form-group">
				<label></label>
				<span id="label1"></span><input id="attr2" style="width: 200px; height: 26px;" type="text" name="attr2" value="{{attr2}}" placeholder="请输入" autocomplete="off">
				<span id="label2"></span><input id="attr3" style="width: 200px; height: 26px;" type="text" name="attr3" value="{{attr3}}" placeholder="请输入" autocomplete="off">
			</div>
			<div class="form-group">
				<label>有效期</label>
				<input style="width: 50px; height: 26px;" type="text" name="periodOfValidity" value="{{periodOfValidity}}" placeholder="请输入" autocomplete="off">
				<select name="timeUnit"  style="width: 150px;">
					<option value="">--请选择--</option>
					<option value="day" {{timeUnit == 'day'?'selected':''}}>天</option>
					<option value="month" {{timeUnit == 'month'?'selected':''}}>月</option>
					<option value="year" {{timeUnit  == 'year'?'selected':''}}>年</option>
				</select>
			</div>
			<%--<div class="form-group" >
				<label>促销内容：</label>
				<textarea rows="3" name="promotionalContent" placeholder="请输入促销内容 ...">{{promotionalContent}}</textarea>
			</div>
--%>
		</div>

	</form>


</script>

<script id="consumeHistoryTemplate" type="text/html">
	<div style="margin:10px;">
		<form id="consumeHistorySearchForm">
			<input type="hidden" name="currentPage" value="1">
			<input type="hidden" name="toolStyle" value="pms">
			<input type="hidden" name="limit" value="10">
			<input type="hidden" name="method" value="loadConsumeHistory">
			<input type="hidden" name="dealerNum" value="${dealerNum}">
			<input type="hidden" name="customerId" value="">
		</form>
	<div class="table">
		<table width="100%">
			<thead>
			<tr>
				<th width="50">序号</th>
				<th width="">客户姓名</th>
				<th width="">订单日期</th>
				<th width="">消费项目</th>
			</tr>
			</thead>
			<tbody id="consumeHistoryDetailTbody" class="detailTr"></tbody>
		</table>
	</div>
	<div class="pageTool" id="consumeHistoryPageTool"></div>
	</div>
</script>

<script id="consumeHistoryDetailTbodyTemplate" type="text/html">
	{{each items as v i}}
	<tr>
		<td rowspan="{{v.details.length}}">{{start + i + 1}}</td>
		<td rowspan="{{v.details.length}}">{{v.customerName}}</td>
		<td rowspan="{{v.details.length}}">{{v.orderDate}}</td>
		<td>{{v.details[0].itemDescription1}}</td>
	</tr>
		{{each v.details as dv i2}}
			{{if i2 > 0}}
				<tr>
					<td>{{dv.itemDescription1}}</td>
				</tr>
			{{/if}}
		{{/each}}
	{{/each}}
	{{if items.length == 0}}
	<tr>
		<td colspan="11" class="none-data-tip">没有相关数据</td>
	</tr>
	{{/if}}
</script>

<script id="historyTemplate" type="text/html">
	<div class="btns " style=" margin:10px 0 0 5px;">
		<button class="green" onclick="showConsumeHistory('${dealerNum}')">消费历史</button>
		<%--<button class="orange">返回</button>--%>
	</div>
	<div style="margin:10px;">
		<form id="historySearchForm">
			<input type="hidden" name="currentPage" value="1">
			<input type="hidden" name="toolStyle" value="pms">
			<input type="hidden" name="limit" value="10">
			<input type="hidden" name="method" value="loadHistory">
			<input type="hidden" name="dealerNum" value="${dealerNum}">
			<input type="hidden" name="customerId" value="">
			<input type="hidden" name="vehicleId" value="">
			<input type="hidden" name="customerName" value="">
		</form>
	<div class="table">
		<table width="100%">
			<thead>
			<tr>
				<th width="50">序号</th>
				<th width="">手机号码</th>
				<th width="">短信内容</th>
				<th width="">发送日期</th>
			</tr>
			</thead>
			<tbody id="historyDetailTbody" class="detailTr"></tbody>
		</table>
	</div>
	<div class="pageTool" id="historyPageTool"></div>
	</div>
</script>

<script id="historyDetailTbodyTemplate" type="text/html">
	{{each items as v i}}
	<tr>
		<td>{{start + i + 1}}</td>
		<td>{{v.mobilePhone}}</td>
		<td>{{v.smsContent}}</td>
		<td>{{v.createDate}}</td>
	</tr>
	{{/each}}
	{{if items.length == 0}}
	<tr>
		<td colspan="11" class="none-data-tip">没有相关数据</td>
	</tr>
	{{/if}}
</script>

<script>
	function changeType() {
		var v = $("#attr1").val();
		if(v == '0'){
			$("#label1").html('买');
			$("#label2").html('赠送');
			$("#attr2").show();
			$("#attr3").show();
		}else if(v == '1'){
			$("#label1").html('买');
			$("#label2").html('减');
			$("#attr2").show();
			$("#attr3").show();
		}else if(v == '2'){
			$("#label1").html('送');
			$("#label2").html('');
			$("#attr2").show();
			$("#attr3").hide();
		}else if(v == '3'){
			$("#label1").html('送');
			$("#label2").html('');
			$("#attr2").show();
			$("#attr3").hide();
		}else if(v == '4'){
			$("#label1").html('');
			$("#label2").html('');
			$("#attr2").show();
			$("#attr3").hide();
		}
	}
</script>

</body>
</html>




